<?php require_once(dirname(__FILE__).'/inc/config.inc.php');IsModelPriv('goodsorder');

require_once "function.php";




 ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>用户数据分析</title>

<!-- Bootstrap Core CSS -->
<link href="ui/css/bootstrap.min.css" rel="stylesheet">
<!-- Morris Charts CSS -->
<link href="ui/css/plugins/morris.css" rel="stylesheet">
<link href="ui/css/sb-admin.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="ui/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
</head>
<style>
.demo-container { position: relative; height: 350px; }
#placeholder { width: 350px; }
</style>
<body>
    <div id="wrapper">
      <div id="page-wrapper">
      	
		<div class="container-fluid">
        
        <div class="row">
          <div class="col-lg-12">
            <ol class="breadcrumb">
              <li><a href="order.php" ><i class="fa fa-dashboard"></i> 统计</a></li>
              <li class="active"><i class="fa fa-bar-chart-o"></i> 报表</li>
            </ol>
            <div class="alert alert-info alert-dismissable">
              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
			  该统计图为为系统实时数据分析。 
             </div>
          </div>
        </div><!-- /.row -->

        <!-- /.row -->

        <div class="row">
          <div class="col-lg-4">
            <div class="panel panel-primary">
              <div class="panel-heading">
                <h3 class="panel-title"><i class="fa fa-long-arrow-right"></i>报修设备统计</h3>
              </div>
              <div class="panel-body">
              
                <div class="flot-chart">
                    <div class="flot-chart-content" id="flot-pie-chart"></div>
                </div>
              
                <div class="text-right">
                  <a href="order.php">查看详情 <i class="fa fa-arrow-circle-right"></i></a>
                </div>
              </div>
            </div>
          </div>
          <div class="col-lg-4">
            <div class="panel panel-primary">
              <div class="panel-heading">
                <h3 class="panel-title"><i class="fa fa-long-arrow-right"></i> 工程师接单统计</h3>
              </div>
              <div class="panel-body">
                <div class="flot-chart">
                    <div class="flot-chart-content" id="flot-pie-chart3"></div>
                </div>
                <div class="text-right">
                  <a href="order.php">查看详情 <i class="fa fa-arrow-circle-right"></i></a>
                </div>
              </div>
            </div>
          </div>
          <div class="col-lg-4">
            <div class="panel panel-primary">
              <div class="panel-heading">
                <h3 class="panel-title"><i class="fa fa-long-arrow-right"></i>用户评价统计（最低为1星， 最高为5星）</h3>
              </div>
              <div class="panel-body">
                <div class="flot-chart">
                    <div class="flot-chart-content" id="flot-pie-chart2"></div>
                </div>
                <div class="text-right">
                  <a href="order.php">查看详情 <i class="fa fa-arrow-circle-right"></i></a>
                </div>
              </div>
            </div>
          </div>
          
        </div><!-- /.row -->

        <div class="row">
                  <div class="col-lg-12">
                    <div class="panel panel-primary">
                      <div class="panel-heading">
                        <h3 class="panel-title"><i class="fa fa-bar-chart-o"></i> 每天提交的报修申请: 最近30天</h3>
                      </div>
                      <div class="panel-body">
                        <div id="morris-chart-area"></div>
                      </div>
                    </div>
                  </div>
                </div>
        
        
        <div class="row">
          <div class="col-lg-12">
             <div class="alert alert-info alert-dismissable">
              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
			  该统计图为 任务类型统计图表。
             </div>
            <div class="panel panel-primary">
              <div class="panel-heading">
                <h3 class="panel-title"><i class="fa fa-bar-chart-o"></i> 所有任务类型统计  （包含进行中的、已经完结的）</h3>
              </div>
              <div class="panel-body">
                <div class="flot-chart">
                  <div id="morris-chart-bar"></div>
                </div>
              </div>
            </div>
          </div>
        </div><!-- /.row -->

        <!-- /.row -->
		</div>
      </div><!-- /#page-wrapper -->

    </div><!-- /#wrapper -->
<!-- /#wrapper --> 

<!-- jQuery --> 
<script type="text/javascript" src="templates/js/jquery.min.js"></script> 

<!-- Bootstrap Core JavaScript --> 
<script src="ui/js/bootstrap.min.js"></script> 

<!-- Morris Charts JavaScript --> 
<script src="ui/js/plugins/morris/raphael.min.js"></script> 
<script src="ui/js/plugins/morris/morris.min.js"></script> 

<!-- Flot Charts JavaScript --> 
<!--[if lte IE 8]><script src="js/excanvas.min.js"></script><![endif]--> 
<script src="ui/js/plugins/flot/jquery.flot.js"></script> 
<script src="ui/js/plugins/flot/jquery.flot.tooltip.min.js"></script> 
<script src="ui/js/plugins/flot/jquery.flot.resize.js"></script> 
<script src="ui/js/plugins/flot/jquery.flot.pie.js"></script> 
<script>//Flot Pie Chart with Tooltips
//Flot Pie Chart with Tooltips
//Flot Pie Chart with Tooltips
// Flot Pie Chart with Tooltips


$(function () {


	var data = [
	<?php
	 $sql = "SELECT count(id) as a,apply_device  FROM `#@__order`  WHERE   delstate=''  group by apply_device ";
		$dosql->Execute($sql,7);
		while($order=$dosql->GetArray(7)){
		$typename=getDeviceName($order['apply_device']);
		$cishu=$order['a'];
		echo  '{ label: "'.$typename   .$cishu.'", data: '.$cishu.' },';
		}
	?>
	];
	
	var plotObj = $.plot($("#flot-pie-chart"), data, {
		series: {
			pie: {
				show: true
			}
		},
		grid: {
			hoverable: true 
		},
		tooltip: true,
		tooltipOpts: {
			content: "%p.0%, %s", // show percentages, rounding to 2 decimal places
			shifts: {
				x: 20,
				y: 0
			},
			defaultTheme: false
		}
	});
	

	
	//  工程师接单统计
	var data3 = [
	<?php
		$dosql->Execute("SELECT *  FROM `#@__user`  WHERE level='3'   ",1);
		while($user_arr=$dosql->GetArray(1)){
	         $mid=$user_arr['id'];
			 $m_name=$user_arr['truename'];
	 		 $sql_0 = "SELECT count(id) as a  FROM `#@__order`   WHERE   FIND_IN_SET('$mid',manageid)    AND   delstate=''   ";
			 $dosql->Execute($sql_0,2);
			 while($order=$dosql->GetArray(2)){
					$cishu=$order['a'];
			}
			echo  '{ label: "'.$m_name   ."  ".$cishu.'", data: '.$cishu.' },';
		}
		
	?>

	];
	
	var plotObj = $.plot($("#flot-pie-chart3"), data3, {
		series: {
			pie: {
				show: true
			}
		},
		grid: {
			hoverable: true 
		},
		tooltip: true,
		tooltipOpts: {
			content: "%p.0%, %s", // show percentages, rounding to 2 decimal places
			shifts: {
				x: 20,
				y: 0
			},
			defaultTheme: false
		}
	});	

	// 服务星级分布
	var data2 = [
	<?php
	 $sql = "SELECT count(id) as a,start  FROM `#@__order_evaluate`    group by start ";
		$dosql->Execute($sql,7);
		while($order=$dosql->GetArray(7)){
		$start=$order['start'];
		$cishu=$order['a'];
		echo  '{ label: "'.$start .'星'  .$cishu.'", data: '.$cishu.' },';
		}
	?>
	];

	
	var plotObj = $.plot($("#flot-pie-chart2"), data2, {
		series: {
			pie: {
				show: true
			}
		},
		grid: {
			hoverable: true 
		},
		tooltip: true,
		tooltipOpts: {
			content: "%p.0%, %s", // show percentages, rounding to 2 decimal places
			shifts: {
				x: 20,
				y: 0
			},
			defaultTheme: false
		}
	});


	
});


Morris.Area({
  // ID of the element in which to draw the chart.
  element: 'morris-chart-area',
  // Chart data records -- each entry in this array corresponds to a point on
  // the chart.
  data: [
 <?php 
// 近30天 报表 
 $sql5="SELECT FROM_UNIXTIME(`post_time` ,'%Y-%m-%d' ) as a,count(id) as b FROM `#@__order`  WHERE  delstate=''  AND  (TO_DAYS( NOW( ) ) - TO_DAYS( FROM_UNIXTIME( `post_time` ,  '%Y%m%d' )) <=30) group by a asc LIMIT 0 , 30"; 
 $dosql->Execute("$sql5",9);  //每天用户列表 
  while($result=$dosql->GetArray(9)){
	  $d=$result['a'];
 	  echo "{ d: '".$d."',visits:".$result['b']."},";
  }
 ?> 

  ],
  // The name of the data record attribute that contains x-visitss.
  xkey: 'd',
  // A list of names of data record attributes that contain y-visitss.
  ykeys: ['visits'],
  // Labels for the ykeys -- will be displayed when you hover over the
  // chart.
  labels: ['提交次数'],
  // Disables line smoothing
  smooth: false,
});

	// 手机号码省份分析 
	Morris.Bar ({
	  element: 'morris-chart-bar',
	  data: [
	<?php
	 $sql = "SELECT count(f.id) as a,t.dataname as repairname  FROM `#@__order` as f
		left join `#@__cascadedata`  as t on t.datavalue=f.repairid  
		WHERE t.datagroup='renwu'   AND   f.delstate=''  group by f.repairid    ";
		$dosql->Execute($sql,1);
		while($order=$dosql->GetArray(1)){
		$repairname=$order['repairname'];
		$cishu=$order['a'];
			echo  '{ jinduname: "'.$repairname.'", geekbench: '.$cishu.' },';
		}
	?>

	  ],
	  xkey: 'jinduname',
	  ykeys: ['geekbench'],
	  labels: ['共'],
	  barRatio: 0.4,
	  xLabelAngle: 90,
	  hideHover: 'auto'
	});


</script>

</body>
</html>